﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using BLL;
using System.Text;
using System.Data;
using System.Collections;

namespace TaoBaoProject.MenbersHandler
{
  /// <summary>
  /// Summary description for GetMenbersHandler
  /// </summary>
  public class GetMenbersHandler : IHttpHandler
  {
    MenbersBLL menbers = new MenbersBLL();
    public void ProcessRequest(HttpContext context)
    {
      context.Response.ContentType = "text/plain";
      string page = context.Request["page"];
      string rows = context.Request["rows"];
      string sort = context.Request["sort"];
      string order = context.Request["order"];
      DataView dv;
      StringBuilder sbRet = new StringBuilder();
      //DataTable dt = menbers.GetAllMenbers();&
      //page = page == null ? "1" : page;
      //rows = rows == null ? "10" : rows;
      //sort = sort == null ? "MenberID" : sort;
      //order = order == null ? "asc" : order;

      //DataTable dt = menbers.GetAllMenbers(rows, page, sort, order);
      DataTable dt = menbers.GetAllMenbers();
      dv = dt.DefaultView;
      dv.Sort = sort + " " + order;
      dt = dv.ToTable();

      dt.Columns.Add("id");
      for (int i = 0; i < dt.Rows.Count; i++)
      {
        dt.Rows[i]["id"] = dt.Rows[i]["MenberID"];
      }

      sbRet.Append(Common.Utility.GetJsonString(dt));

      context.Response.Write(sbRet);

    }
    public bool IsReusable
    {
      get
      {
        return false;
      }
    }
  }
}